package com.moyun.finance.controller;

import com.moyun.finance.entity.Receivables;
import com.moyun.finance.entity.Response;
import com.moyun.finance.service.ReceivablesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;


@RestController
@RequestMapping("/receivables")
public class ReceivablesController {
    @Autowired
    ReceivablesService rs;

    //应收(付)信息新增
    @RequestMapping("/save")
    public @ResponseBody Response save(@RequestBody Receivables r){
        Response res = rs.save(r);
        return res;
    }

    //应收(付)信息删除
    @RequestMapping("/delete")
    public @ResponseBody Response delete(@RequestBody Receivables r){
        Response res = rs.delete(r);
        return res;
    }

    //应收(付)金额修改
    @RequestMapping("/updateMoney")
    public @ResponseBody Response update(@RequestBody Receivables r){
        Response res = rs.update(r);
        return res;
    }

    //应收列表
    @RequestMapping("/findReceivablesList")
    public @ResponseBody Response findReceivablesList(String companyId) throws ParseException{
        Response res = rs.findReceivablesList(companyId);
        return res;
    }

    //应付列表
    @RequestMapping("/findPaymentList")
    public @ResponseBody Response findPaymentList(String companyId) throws ParseException{
        Response res = rs.findPaymentList(companyId);
        return res;
    }

    //根据id查
    @RequestMapping("/findOne")
    public @ResponseBody Response findOne(String receivablesId) throws ParseException{
        Response res = rs.findOne(receivablesId);
        return res;
    }
}
